home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 8: LINUX Games
/
Linux Cubed Series 8 - LINUX Games.iso
/
games
/
x11
/
rpg
/
crossfir.92
/
crossfir
/
crossfire-0.92.5
/
include
/
global.h
< prev
next >
Wrap
C/C++ Source or Header
|
1996-07-24
|
9KB
|
293 lines
/*
* static char *rcsid_global_h =
* "$Id: global.h,v 1.29 1996/03/04 09:58:32 master Exp $";
*/
/*
CrossFire, A Multiplayer game for X-windows
Copyright (C) 1992 Frank Tore Johansen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author can be reached via e-mail to frankj@ifi.uio.no.
*/
#ifndef GLOBAL_H
#define GLOBAL_H
#ifndef EXTERN
#define EXTERN extern
#endif
#include "includes.h"
#define NUM_COLORS 13
#define XDRAWIMAGESTRING(disp,win,gc,x,y,str,len) \
XDrawImageString16(disp,win,gc,x,y,str,len)
#define FontindexToXChar(s) fontindex_to_XChar2b(s)
#define XCharToFontindex(s) ((Fontindex) ((s).byte1*256 + (s).byte2))
typedef unsigned short Fontindex;
typedef XChar2b XChar;
#include "structs.h"
#if defined(SOUND_EFFECTS) && !defined(__CEXTRACT__)
#include <rplay.h> /* RPLAY structure */
#endif
/*****************************************************************************
* GLOBAL VARIABLES: *
*****************************************************************************/
extern char *colorname[NUM_COLORS][2];
extern New_Face *new_faces;
/*
* These are the beginnings of linked lists:
*/
EXTERN player *first_player;
EXTERN mapstruct *first_map;
EXTERN treasurelist *first_treasurelist;
EXTERN artifactlist *first_artifactlist;
EXTERN archetype *first_archetype;
EXTERN objectlink *first_friendly_object; /* Objects monsters will go after */
EXTERN sockets *first_socket; /* Start of linked list of sockets */
/*
* The editor uses these (will get them out of here later):
*/
EXTERN long fix_fontpath;
EXTERN int synchronize;
EXTERN long no_color;
EXTERN long editor; /* if true, edit maps instead of playing (almost obsolete) */
EXTERN int write_state; /* 1= write to level, 2=write to name */
EXTERN int write_pos; /* Position in write_buf */
EXTERN int write_d; /* Which position in the button we start writing from */
EXTERN int button_flag;
EXTERN int last_bard;
EXTERN int fix_walls;
EXTERN int monsters;
EXTERN int generators;
EXTERN int hidden;
EXTERN int others;
/*
* Variables set by different flags (see init.c):
*/
EXTERN int maplevel;
EXTERN long delete_last_file;
EXTERN long warn_archetypes; /* If true, write warnings when failing */
/* to find archetypes when loading from file */
EXTERN long init_done; /* Ignores signals until init_done is true */
EXTERN long trying_emergency_save; /* True when emergency_save() is reached */
EXTERN LogLevel debug; /* Set with -d flag */
EXTERN long default_split_window; /* Set with -w flag */
EXTERN long dump_monsters; /* Set with -m flag */
EXTERN int use_pixmaps; /* Set with -pix flag */
EXTERN int color_pix; /* Set with -xpm flag */
EXTERN long nroferrors; /* If it exceeds MAX_ERRORS, call fatal() */
EXTERN long pticks; /* used by various function to determine */
/* how often to save the character */
/*
* Global pointers to the original argv, argc and genv given to main()
*/
EXTERN int gargc;
EXTERN char **gargv,**genv;
/*
* Misc global variables:
*/
EXTERN FILE *logfile; /* Used by server/daemon.c */
EXTERN int exiting; /* True if the game is about to exit */
EXTERN int server_mode; /* True if the game is in server mode */
EXTERN char *name; /* The name of the game, usually "crossfire" */
EXTERN long last_micro; /* When process_active_maps() was last exec */
EXTERN long nroftreasures; /* Only used in malloc_info() */
EXTERN long nrofartifacts; /* Only used in malloc_info() */
EXTERN long nrofallowedstr; /* Only used in malloc_info() */
/* global stuff used by MULTI god hack -b.t. */
#define MAX_RACES 10
#define MAX_RACE_MEMBERS 20
EXTERN god Gods[NROFGODS];
EXTERN char summoned_monsters[MAX_RACES][MAX_RACE_MEMBERS][MAX_BUF];
/* global stuff used by new skill/experience system -b.t. */
#define MAX_EXP_CAT 7 /* This should be => # of exp obj in the game
* remember to include the "NULL" exp object
* EXP_NONE as part of the overall tally.
*/
#define EXP_NONE (MAX_EXP_CAT - 1) /* "NULL" exp. object. This is the last
* experience obj always.*/
EXTERN short nrofexpcat; /* Current number of experience categories in the game */
EXTERN object *exp_cat[MAX_EXP_CAT]; /* Array of experience objects in the game */
EXTERN archetype *empty_archetype; /* Nice to have fast access to it */
EXTERN archetype *map_archeytpe;
EXTERN char *chrfont;
EXTERN char first_map_path[MAX_BUF]; /* The start-level */
#ifdef LONGJUMP
EXTERN jmp_buf jump_addr;
#endif
EXTERN Atom Protocol_atom, Kill_atom;
EXTERN XClientMessageEvent *cmev;
EXTERN char errmsg[HUGE_BUF];
EXTERN long ob_count;
/*
* Used in treasure.c
*/
EXTERN archetype *ring_arch,*amulet_arch,*staff_arch,*crown_arch;
EXTERN char *undead_name; /* Used in hit_player() in main.c */
EXTERN sockets *active_socket;
EXTERN int freearr_x[SIZEOFFREE], freearr_y[SIZEOFFREE];
EXTERN int maxfree[SIZEOFFREE], freedir[SIZEOFFREE];
EXTERN New_Face *blank_face;
EXTERN New_Face *blocked_face;
EXTERN New_Face *stipple1_face;
EXTERN New_Face *stipple2_face;
EXTERN New_Face *potion_face;
EXTERN MapLook blank_look;
EXTERN New_Face *inv_curse_face, *inv_damn_face, *inv_equip_face, *inv_lock_face,
*inv_magic_face, *inv_unpaid_face;
#ifdef SOUND_EFFECTS
EXTERN RPLAY *sound_table[NROF_SOUNDS];
#endif
EXTERN char *LibDir;
EXTERN char *FontDir;
EXTERN char *PlayerDir;
EXTERN char *MapDir;
EXTERN char *ArcheTypes;
EXTERN char *Treasures;
#ifdef UNIQUE_ITEMS
EXTERN char *ItemsDir;
#endif
extern long max_time; /* loop time */
EXTERN char *font_graphic;
#ifndef __CEXTRACT__
#include <xdir.h>
#include "libproto.h"
#endif
#ifdef __hpux__ /* Must do this after including proto.h */
#define strdup_local(str) strdup(str);
#endif
#define set_map(M,X,Y,C) ((M)->map[(X)+((M)->mapx*(Y))]=*(C))
#define get_map(M,X,Y) (&(M)->map[(X)+((M)->mapx*(Y))])
#define set_map_ob(M,X,Y,tmp) ((M)->map_ob[(X)+((M)->mapx*(Y))]=(tmp))
#define get_map_ob(M,X,Y) ((M)->map_ob[(X)+((M)->mapx*(Y))])
#define out_of_map(M,X,Y) ((X)<0||(X)>=(M)->mapx||(Y)<0||(Y)>=(M)->mapy)
#define get_map_floor(M,X,Y) (&(M)->floor[(X)+((M)->mapx*(Y))])
#ifdef DOUBLE_FLOOR
#define get_map_floor2(M,X,Y) (&(M)->floor2[(X)+((M)->mapx*(Y))])
#define set_map_floor2(M,X,Y,C) ((M)->floor2[(X)+((M)->mapx*(Y))]=*(C))
#endif
#define decrease_ob(xyz) decrease_ob_nr(xyz,1)
#ifdef CALLOC
#undef CALLOC
#endif
#ifdef USE_CALLOC
# define CALLOC(x,y) calloc(x,y)
# define CFREE(x) cfree(x)
#else
# define CALLOC(x,y) malloc(x*y)
# define CFREE(x) free(x)
#endif
/*
* Made this a macro since it's mostly used in time-critical areas:
* (Hopefully a good optimizer will be able to move the if() out of
* any loop where this macro is used. That wouldn't have been possible
* if this was a function!)
*/
/*
* Have two version of this macro. One if Xpm_Pix is defined, another
* if Xpm_Pix is not defined. IT would be better to actually have the
* #ifdef's inside the macro itself, instead of having two versions, but
* I was not able to get that to work.
* Mark Wedel (master@rahul.net)
*/
#ifdef Xpm_Pix
#define draw_face(pl,win,gc,x,y,face) \
{ \
if (pl->color_pixmaps) \
{ \
XSetClipMask(pl->gdisp, gc, pl->masks[(face)]); \
XSetClipOrigin(pl->gdisp, gc, x, (y) - 24); \
XCopyArea(pl->gdisp, pl->pixmaps[(face)], win, gc, 0, 0, 24, 24, \
(unsigned int) (x), (unsigned int) ((y) - 24)); \
} \
else if(pl->use_pixmaps) \
{ \
XCopyPlane(pl->gdisp,pl->pixmaps[(face)],win,gc,0,0,24,24, \
(unsigned int) (x),(unsigned int) ((y) - 24),1); \
} \
else \
{ \
XChar buf; \
buf = FontindexToXChar((Fontindex) (face)); \
XDRAWIMAGESTRING(pl->gdisp,win,gc,x,y,&buf,1); \
} \
}
#else
#define draw_face(pl,win,gc,x,y,face) \
{ \
if(pl->use_pixmaps) \
{ \
XCopyPlane(pl->gdisp,pl->pixmaps[(face)],win,gc,0,0,24,24, \
(unsigned int) (x),(unsigned int) ((y) - 24),1); \
} \
else \
{ \
XChar buf; \
buf = FontindexToXChar((Fontindex) (face)); \
XDRAWIMAGESTRING(pl->gdisp,win,gc,x,y,&buf,1); \
} \
}
#endif
/*
* Have to define LOG() to nothing if NO_LOG is defined.
*/
#ifdef NO_LOG
#define LOG()
#endif
#endif /* GLOBAL_H */